﻿#include "alarmreq.h"

AlarmReq::AlarmReq() : BaseMsg(MSG_TYPE_ALARM_REQ)
{

}

AlarmReq::AlarmReq(int alarmType, SString alarmMode, SString alarmData) : BaseMsg(MSG_TYPE_ALARM_REQ)
{
    this->alarmType = alarmType;
    this->alarmMode = alarmMode;
    this->alarmData = alarmData;
}

AlarmReq::~AlarmReq()
{

}

int AlarmReq::decodeParametersFromTlv(TLV *tlv)
{
    if (tlv->tag == AlarmReqTag_alarmType)
    {
        this->alarmType = tlv->getIntValue();
    }
    else if (tlv->tag == AlarmReqTag_alarmMode)
    {
        this->alarmMode = tlv->buffer;
    }
    else if (tlv->tag == AlarmReqTag_alarmData)
    {
        this->alarmData = tlv->buffer;
    }

    return f_success;
}

int AlarmReq::encodeParametersIntoTlvs(list<TLV *> &tlvs)
{
    tlvs.push_back(createTlvByIntValue(AlarmReqTag_alarmType, alarmType));
    tlvs.push_back(createTlvByStringValue(AlarmReqTag_alarmData, alarmData));
    tlvs.push_back(createTlvByStringValue(AlarmReqTag_alarmMode, alarmMode));

    return f_success;
}
